//
//  ZJQADetailTableViewCell.m
//  ShangHaiHuDongApp
//
//  Created by ZJ on 2017/6/22.
//  Copyright © 2017年 刘应平. All rights reserved.
//

#import "ZJQADetailTableViewCell.h"

@interface ZJQADetailTableViewCell ()
/** 问题 */
@property (nonatomic, strong) UILabel *label;
/** 问题内容 */
@property (nonatomic, strong) UILabel *contentLabel;
/** 分割线 */
@property (nonatomic, strong) UILabel *spaceLabel;
@end

@implementation ZJQADetailTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        [self.contentView addSubview:self.spaceLabel];
        [self.contentView addSubview:self.label];
        [self.contentView addSubview:self.contentLabel];
        
        self.label.sd_layout
        .topSpaceToView(self.contentView, 12 * [UIScreen zj_screenHScale])
        .leftSpaceToView(self.contentView, 12 * [UIScreen zj_screenWScale])
        .widthIs(80 * [UIScreen zj_screenWScale])
        .heightIs([NSString heightWithTextFont:self.label.font]);
    
        
        self.contentLabel.sd_layout
        .topSpaceToView(self.label, 8 * [UIScreen zj_screenHScale])
        .leftEqualToView(self.label)
        .widthIs([UIScreen zj_screenWith] - 24 * [UIScreen zj_screenWScale])
        .heightIs(10);
        
        self.spaceLabel.sd_layout
        .bottomSpaceToView(self.contentView, 0)
        .leftSpaceToView(self.contentView, 12 * [UIScreen zj_screenWScale])
        .rightSpaceToView(self.contentView, 12 * [UIScreen zj_screenWScale])
        .heightIs(1);
    }
    return self;
}










#pragma mark - Setter
- (void)setModel:(ZJQADetailCellModel *)model{
    _model = model;
    self.contentLabel.text = model.ANSWER;
    
    self.contentLabel.sd_layout
    .topSpaceToView(self.label, 8 * [UIScreen zj_screenHScale])
    .leftEqualToView(self.label)
    .widthIs([UIScreen zj_screenWith] - 24 * [UIScreen zj_screenWScale])
    .heightIs([self.contentLabel getLableSizeWithMaxWidth:self.contentLabel.width].height);
    
    [self.contentLabel updateLayout];
    self.label.text = [NSString stringWithFormat:@"回答%ld :",self.indexPath.row + 1];
}

#pragma mark - Getters

- (UILabel *)label{
    if (_label == nil){
        _label = [UILabel new];
        _label.textColor = [UIColor themeColor];
        _label.text = @"问题 :";
        _label.font = [UIFont titleTextFont];
    }
    return _label;
}

- (UILabel *)contentLabel{
    if (_contentLabel == nil){
        _contentLabel = [UILabel new];
        _contentLabel.textColor = [UIColor textBlackColor];
        _contentLabel.font = [UIFont titleTextFont];
        _contentLabel.characterSpace = 1;
        _contentLabel.lineSpace = 4 * [UIScreen zj_screenHScale];
        _contentLabel.numberOfLines = 0;
    }
    return _contentLabel;
}
- (UILabel *)spaceLabel{
    if (_spaceLabel == nil){
        _spaceLabel = [UILabel new];
        _spaceLabel.backgroundColor = [UIColor zj_colorWithHexString:@"ebebeb"];
    }
    return _spaceLabel;
}
@end
